﻿using AutoMapper;
using AutoMapperDemo.DTO;
using AutoMapperDemo.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace AutoMapperDemo
{
    public class MappingProfile : Profile
    {
        public MappingProfile()
        {
            CreateMap<User, UserDto>()
                .ForMember(m => m.UserName, o => o.MapFrom(f => f.Name))
                .ForMember(m => m.ClassInfoDtos, o => o.MapFrom(f => f.ClassInfos));
            CreateMap<UserDto, User>()
                .ForMember(m => m.Age, o => o.Ignore());
            CreateMap<ClassInfo, ClassInfoDto>();
            CreateMap<ClassInfoDto, ClassInfo>();
        }
    }
}
